import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:hao/page/launch/LaunchViewModel.dart';
// import 'package:mini_bmob/mini_bmob.dart';
import 'package:shared_preferences/shared_preferences.dart';

class LoginViewModel extends GetxController {
  final TextEditingController phoneController = TextEditingController();
  final TextEditingController pwdController = TextEditingController();
  final obscure = true.obs;

  void loginClick() {
    if (phoneController.text.isEmpty) {
      Fluttertoast.showToast(msg: "请输入手机号");
      return;
    }

    if (pwdController.text.isEmpty) {
      Fluttertoast.showToast(msg: "请输入密码");
      return;
    }

    // BmobUserTable _user = BmobUserTable(
    //     username: phoneController.text, password: pwdController.text);
    // _user.login().then((value) async {
    //   if (value) {
    //     SharedPreferences preferences = await SharedPreferences.getInstance();
    //     preferences.setBool("hasLogin", true);
    //     LaunchViewModel _viewModel = Get.find();
    //     _viewModel.changeLoginState();
    //     phoneController.clear();
    //     pwdController.clear();
    //     Get.delete(tag: "LoginViewModel");
    //   } else {
    //     Fluttertoast.showToast(msg: "账号或密码错误");
    //   }
    // });
  }
}
